<template>
  <div class="tiktok-write-off-equity">
    <p class="title">权益列表</p>
    <p class="tips">{{ status == 2 ? '点击上方确定核销，核销成功后您将获得以下权益：' : '您已成功核销，恭喜您获得以下权益，赶紧查收吧！！' }}</p>
    <div class="list" v-if="status == 3">
      <div class="center" style="width: 100%;margin-bottom: 1.25rem;justify-content: space-between;"
        v-for="item in info.single">
        <div class="center">
          <i :class="'iconfont ' + item.icon"
            style="width: 2.5rem !important;height: 2.5rem !important;background-size: 2.5rem !important;"></i>
          <div class="item">
            <span class="money" v-if="item.icon !== 'senior-member'">+{{ item.value }}</span>
            <span style="flex-shrink: 0;" class="bold" v-else>升级到</span>
            <span class="bold" style="text-wrap: nowrap;">{{ item.name }}</span>
          </div>
        </div>
        <button class="button" @click="goto(item.type)">去查看</button>
      </div>
      <div v-for="(item, index) in info && info.exchange" class="exchange-wrapper" :key="index">
        <div class="center">
          <i :class="'iconfont ' + item.icon"></i>
          <div class="item">
            <span class="money">+{{ item.value }}张</span>
            <span class="bold" style="text-wrap: nowrap;">{{ item.name }}</span>
          </div>
        </div>
        <button class="button" @click="goto(item.type)">去查看</button>

      </div>
    </div>
    <template v-if="status == 2">
      <div class="center" style="flex-wrap: wrap;">
        <div v-for="(item, index) in info && info.single" class="single-wrapper" :key="index">
          <i :class="'iconfont ' + item.icon"></i>
          <div class="item">
            <span class="money" v-if="item.icon !== 'senior-member'">+{{ item.value }}</span>
            <span style="flex-shrink: 0;" class="bold" v-else>升级到</span>
            <span class=" item-name">{{ item.name }}</span>
          </div>
        </div>
        <div v-for="(item, index) in info && info.exchange" class="w-50 center mb-20 text-left" :key="index">
          <i :class="'iconfont ' + item.icon"></i>
          <div class="item">
            <span class="money">+{{ item.value }}张</span>
            <span class="bold" style="text-wrap: nowrap;">{{ item.name }}</span>
          </div>
        </div>
      </div>
    </template>
    <div style="padding: 0.75rem;background: #FFF9F2;border-radius: 0.5rem;"  v-if="goods && goods.length !== 0">
      <div class="order" v-for="item in goods" :key="item.id">
        <div class="between" v-if="item.order_sn" style="margin-bottom: 0.625rem;">
          <span class="order-number">订单编号：{{ item.order_sn }}</span>
          <button class="button" style="flex-grow: 0;" @click="order_handle(item.order_id)">去查看</button>
        </div>
        <div class="goods">
          <img class="img" :src="item.thumb" alt="" />
          <div class="goods-right">
            <div class="between left baseline mb-18">
              <div class="goods-title mr-34">{{ item.name }}</div>
              <div class="c-F15353">¥{{ item.price }}</div>
            </div>
            <div class="shrink between baseline">
              <div class=" mr-34 c-6E6E79"><template v-if="item.option_name">规格：{{ item.option_name }}</template></div>
              <div class="c-6E6E79">x{{ item.value }}</div>
            </div>

          </div>
        </div>
      </div>

    </div>
    <div class="award-bottom" v-if="info.coupon && info.coupon.length !== 0">
      <div style="display: flex;flex-wrap: nowrap;">
        <div class="award-bottom-item" v-for="(item, index) in info.coupon" :class="index > 2 ? 'mr-111' : 'mr-167'">
          <div class="face-value" v-if="Number(item.discount)>0" style="display: flex;align-items:baseline;">
            <span style="text-wrap:nowrap;">{{ item.discount }}</span>
            <span style="font-size:0.75rem">折</span>
          </div>
          <div class="face-value" v-else><span style="font-size:0.75rem">￥</span>{{ item.deduct }}</div>
          <p class="full-condition">满{{ item.enough }}可用{{ item.value }}张</p>
          <div class="award-line" :class="{ 'r-20': index <= 2 }" v-if="index + 1 !== info.coupon.length"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    datas: {
      type: Object,
      default: () => {
        return {};
      }
    },
    status: {
      type: Number,
      default: 3,
    }
  },
  data() {
    return {
      info: {},
      goods: [],
    };
  },
  methods: {
    order_handle(order_id) {
      this.$router.push(this.fun.getUrl('orderdetail', { order_id }));
    },
    getOrder(id) {
      $http.get("plugin.tiktok-verify-ticket.api.record.detail", { id }, "").then(({ result, msg, data }) => {
        if (result !== 1) {
          return this.$toast(msg);
        }
        console.log(data, "data====");
        this.info = data.right;
        this.goods = data.right.good;
        console.log(this.goods, "goods");
      })
    },
    goto(type) {
      let _url = {
        "point": "integral_v2",
        "balance": "balance",
        "love": "love_index",
        "integral": "Integral_love",
        "packet": "DailyRed",
        "exchange": "redeem_code_list",
        "member_level": "MemberGradeList"
      }
      this.$router.push(this.fun.getUrl(_url[type]))
    }
  },
  watch: {
    "datas": {
      handler(newV, oldV) {
        console.log(newV, "newV======");
        if (newV && newV.length !== 0) {
          this.goods = newV.good;
          this.info = newV;
        }
      },
      deep: true,
      immediate: true
    }
  }
};
</script>

<style scoped lang="scss">
.single-wrapper {
  width: 50%;
  display: flex;
  align-items: center;
  margin-bottom: 0.625rem;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tiktok-write-off-equity {
  .exchange-wrapper {
    width: 100%;
    margin-bottom: 1.25rem;
    justify-content: space-between;
    align-items: center;
    display: flex;

    .iconfont {
      width: 2.5rem !important;
      height: 2.5rem !important;
      background-size: 2.5rem !important;
    }
  }

}

.w-50 {
  width: 50%;
}

.mb-20 {
  margin-bottom: 0.625rem;
}

.text-left {
  text-align: left;
}

.tiktok-write-off-equity {
  margin: 0.625rem 0.75rem;
  padding: 0.9375rem 0.75rem;
  border-radius: 0.625rem;
  background-color: #fff;

  .r-20 {
    right: 25% !important;
  }

  .award-line {
    position: absolute;
    right: 20%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #EEDCC9;
  }

  .face-value {
    position: relative;
    display: inline-block;
    padding: 0.6563rem 0.9688rem;
    background: linear-gradient(153deg, #F6B073 0%, #EB544A 100%);
    border-radius: 0.5rem;
    color: #fff;
    font-size: 1.25rem;
  }

  .face-value::after {
    content: "";
    position: absolute;
    width: 0.6875rem;
    height: 0.6875rem;
    background: #FDF5EC;
    right: 0;
    top: 50%;
    border-radius: 100px;
    transform: translate(50%, -50%);
  }

  .full-condition {
    color: #AA5732;
    font-weight: 500;
    font-size: 0.8125rem;
    white-space: nowrap;
    margin: 0.6563rem 0;
  }

  .face-value::before {
    content: "";
    position: absolute;
    width: 0.6875rem;
    height: 0.6875rem;
    background: #FDF5EC;
    left: 0;
    top: 50%;
    border-radius: 100px;
    transform: translate(-50%, -50%);
  }

  .award-bottom-item {
    position: relative;
    text-wrap:nowrap;

    // &:last-child {
    //   padding-right: 0 !important;
    // }
  }


  .award-bottom {
    margin-top: 0.625rem;
    position: relative;
    display: flex;
    flex-direction: column;
    background: #FDF5EC;
    border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
    padding: 1.3438rem 2.5938rem 0.7188rem;
    overflow-x: scroll;

    .mr-167 {
      padding-right: 5.2188rem;
    }

    .mr-111 {
      padding-right: 3.4688rem;
    }
  }

  .bold {
    font-weight: bold;
    font-size: 0.875rem;
  }

  .between {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .order-number {
    font-weight: bold;
    font-size: 0.8125rem;
    text-align: left;
    white-space: nowrap;
    width: calc(100% - 25%);
    overflow-x: scroll;
  }

  .mb-18 {
    margin-bottom: 0.5625rem;
  }

  .baseline {
    align-items: baseline !important;
  }

  .c-F15353 {
    color: #F15353;
  }

  .mr-34 {
    margin-right: 1.0625rem;
  }

  .left {
    text-align: left;
  }

  .righ {
    text-align: right;
  }

  .column {
    display: flex;
    justify-content: space-between;
    flex-direction: column;
  }

  .goods-title {
    white-space: pre-wrap;
  }

  .shrink {
    flex-shrink: 0;
  }

  .c-6E6E79 {
    color: #6E6E79;
  }

  .goods {
    display: flex;
    align-items: center;
    font-size: 0.8125rem;
  }
  .goods-right {
    flex: 1;
    // display: flex;
    // justify-content: space-between;
    // align-items: center;
  }

  .img {
    flex-shrink: 0;
    width: 4.25rem;
    height: 4.25rem;
    border-radius: 0.5rem;
    margin-right: 0.4063rem;
    margin-left: 0;
  }

  .button {
    width: 4.375rem;
    height: 1.75rem;
    background: var(--themeBaseColor);
    ;
    border-radius: 1.875rem;
    color: #fff;
    border: none;
  }

  .center {
    display: flex;
    align-items: center;
  }

  .iconfont {
    flex-shrink: 0;
    display: inline-block;
    background-size: 1.8125rem !important;
    width: 1.8125rem !important;
    height: 1.8125rem !important;
  }

  .item-name {
    max-width: 6.25rem;
    font-weight: bold;
    text-wrap: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .item {
    flex: 1;
    display: flex;
    align-items: center;
    margin-left: 0.2813rem;
    flex-wrap: nowrap;
    // overflow: hidden;
    // text-overflow: ellipsis;
    // margin-right: 0.1563rem;
  }


  .fz-26 {
    font-size: 0.8125rem;
  }

  .order {
    margin-bottom: 0.6563rem;
  }
  .order:last-child{
    margin-bottom: 0 !important;
  }

  .list {
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: space-between;
  }

  .money {
    color: #F15353;
    font-size: 0.875rem;
    flex-shrink: 0;
  }

  .title {
    font-size: 1rem;
    text-align: left;
    font-weight: bold;
    color: #00001C;
  }

  .tips {
    color: var(--themeBaseColor);
    ;
    font-size: 0.75rem;
    text-align: left;
    margin-top: 0.4375rem;
    margin-bottom: 1.0625rem;
  }

  .balance {
    background: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/pay_success/balance.png") no-repeat center;
  }

  .balance::before {
    content: "";
  }

  .packet {
    background: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/pay_success/limit.png") no-repeat center;
  }

  .packet::before {
    content: "";
  }

  .integral {
    background: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/pay_success/integral.png") no-repeat center;
  }

  .integral::before {
    content: "";
  }

  .Integral_love {
    background: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/pay_success/points.png") no-repeat center;

  }

  .Integral_love::before {
    content: "";
  }

  .love {
    background: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/pay_success/love_point.png") no-repeat center;
  }

  .love::before {
    content: "";
  }

  .exchange {
    background: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/dy-verification-certificate/coupon.png") no-repeat center;
  }

  .exchange::before {
    content: "";
  }

  .senior-member {
    background: url("https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/dy-verification-certificate/senior-member.png") no-repeat center;
  }

  .senior-member::before {
    content: "";
  }

}
</style>
